package com.jarvis.hospital.prescription.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.hospital.R;
import com.jarvis.hospital.prescription.model.BloodDetailModel;
import com.jarvis.hospital.prescription.model.BloodTimeModel;
import com.jarvis.hospital.prescription.model.PrescriptionDetailModel;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class BloodAdapter extends BaseQuickAdapter<BloodDetailModel> {
    private int type;

    public BloodAdapter(int layoutResId, List<BloodDetailModel> data, int type) {
        super(layoutResId, data);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, BloodDetailModel bloodDetailModel) {
        baseViewHolder
                .setText(R.id.tv_time, bloodDetailModel.getDoBloodTime())
                .setText(R.id.tv_patient_bed_no, bloodDetailModel.getPatientBedNumber())
                .setText(R.id.tv_patient_name, bloodDetailModel.getPatientName())
                .setText(R.id.tv_name, bloodDetailModel.getNurseName())
                .setText(R.id.tv_analysis, bloodDetailModel.getAnalysisText())
                .setText(R.id.tv_inteval, bloodDetailModel.getDrawTimeInteval())
                .setText(R.id.tv_plan_time, bloodDetailModel.getPlanBloodTime())
                .addOnClickListener(R.id.img_analysis);;
        ImageView img_analysis = baseViewHolder.getView(R.id.img_analysis);
        if(TextUtils.isEmpty(bloodDetailModel.getAnalysisPic())){
            img_analysis.setVisibility(View.GONE);
        }else {
            img_analysis.setVisibility(View.VISIBLE);
        }
        Glide.with(mContext)
                .load(bloodDetailModel.getAnalysisPic())
                .error(R.drawable.img_main_bg)
                .into(img_analysis);
    }
}
